from flask import Blueprint, render_template, redirect, url_for, request
from models import Reader
from app import db

reader = Blueprint('reader', __name__, template_folder='templates')


@reader.route('/')
def index():
    readers = Reader.query.all()
    return render_template('reader/show.html', reader=readers and readers[0] or None, readers=readers)


@reader.route('/add', methods=['GET', 'POST'])
def add():
    return render_template('reader/add.html')


@reader.route('/<id>')
def show(id):
    reader = Reader.query.get(id)
    return render_template('reader/show.html', reader=reader, readers=Reader.query.all())


@reader.route('/<id>/del/')
def delete(id):
    return 'Deleted'

